<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <input type="text">
  <button id="cancel">取消</button>
  <!-- <script src="https://cdn.jsdelivr.net/npm/underscore@1.13.2/underscore-umd-min.js"></script> -->
  <script src="./00_dictation.js"></script>

  <script>
    const inputEl = document.querySelector("input")
    let count = 1;
    const inputChange = function(event) {
      console.log(`发送了第${count++}网络请求`, this, event);

      return "abc";
    }
    // 防抖处理
    const debounceChange = debounce(inputChange, 3000, true, (res) => {
      console.log("真正的数据", res);
    });

    inputEl.oninput = debounceChange;
    // 节流处理
    // inputEl.oninput = _.throttle(inputChange, 2000);

    // 取消功能
    const cancelBtn = document.querySelector("#cancel");
    cancelBtn.onclick = function() {
      debounceChange.cancel()
    }
  </script>
  
</body>
</html>